package com.linkage.jz.bankruptcy.activity.Project.ZQUser;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.linkage.jz.bankruptcy.BankruptcyApp;
import com.linkage.jz.bankruptcy.Consts;
import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ChangerLegalRepActivity;
import com.linkage.jz.bankruptcy.adapter.CommonTabPagerAdapter;
import com.linkage.jz.bankruptcy.bean.MyProInfo;
import com.linkage.jz.bankruptcy.bean.ZQBaseInfo;
import com.linkage.jz.bankruptcy.bean.ZQUserDetailAuthBaseInfo;
import com.linkage.jz.bankruptcy.bean.ZQUserDetailBaseInfo;
import com.linkage.jz.bankruptcy.event.RefreshEvent;
import com.linkage.jz.bankruptcy.fragment.Project.ZQUserBaseDetailFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ZQUserOperateBaseFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ZQUserZQBaseDetailFragment;
import com.linkage.jz.bankruptcy.net.BaseSubscriber;
import com.linkage.jz.bankruptcy.net.Network;
import com.linkage.jz.bankruptcy.utils.SPUtils;
import com.linkage.jz.bankruptcy.utils.SignUtil;
import com.linkage.jz.bankruptcy.widget.CreateZQUserNoticeDialog;
import com.linkage.jz.bankruptcy.widget.LoginNoticeDialog;
import com.linkage.jz.bankruptcy.widget.PopupMenuPublicPro;
import com.linkage.jz.bankruptcy.widget.PublicNoticeDialog;
import com.linkage.jz.bankruptcy.widget.ShapeLoadingDialog;
import com.linkage.seapeak.activity.chat.ChatDetailActivity;
import com.linkage.seapeak.activity.project.DissentAddActivity;
import com.linkage.seapeak.base.BaseActivity;
import com.linkage.seapeak.utils.CommonUtils;
import com.linkage.seapeak.utils.ToastUtil;
import com.linkage.seapeak.view.QuickPopView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONObject;

import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Random;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.Headers;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;


public class ZQUserDetailActivity extends BaseActivity implements CommonTabPagerAdapter.TabPagerListener {

    PublicNoticeDialog noticeDialog;

    Toolbar toolbar;
    CollapsingToolbarLayout collapsingToolbar;
    TabLayout tabLayout;
    AppBarLayout appbar;
    ViewPager viewpager;
    private String proid;
    private ShapeLoadingDialog shapeLoadingDialog;

    //    TextView tv_proname,tv_managename,tv_manageaddr,tv_manageuser;
    ImageView iv_proimg;

    private CommonTabPagerAdapter adapter;
    private static String strZQId;
    private static String creditorId;
    private ZQUserDetailBaseInfo mInfo;

    private TextView tv_user_status, tv_send_notice, tv_online, tv_username, tv_tag1, tv_tag2, tv_tag3;

    private TextView tv_tag, tv_item_bgaswipe_title1, tv_item_bgaswipe_title2,tv_china;
    private LinearLayout sendmsg, ll_tag, ll_item_bgaswipe_title4;

    private ImageView iv_phone,iv_email;
    private String name ;
    private String phone ;

    private TextView popClick;

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {


        return true;
    }

    private  Boolean showFlag;
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        System.out.println("onPrepareOptionsMenu");
        menu.clear();

        if (mInfo != null && mInfo.getOpStatus() != null) {
//            if (!"0".equalsIgnoreCase(mInfo.getOpStatus())) {
//                getMenuInflater().inflate(R.menu.menu_project_detail_zqr, menu);
//
//            }
            try {
                //已拒绝
//                if ("0".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
////                return false;
//                    if ("3".equalsIgnoreCase(mInfo.getNoticeStatus())) {
////                        findViewById(R.id.menu_ddd).setVisibility(View.INVISIBLE);
//                        return false;
//                    }
//                } else if ("1".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
//
////                    if ("2".equalsIgnoreCase(mInfo.getIdentityStatus().getValue())) {
////                        findViewById(R.id.menu_ddd).setVisibility(View.INVISIBLE);
//
//                    if("2".equalsIgnoreCase(mInfo.getDataStatus().getValue()) )
//                    {
//                        if ("0".equalsIgnoreCase(mInfo.getIdentityStatus().getValue())) {
////                            tv_user_status.setText("身份待验证");
//                            return false;
//
//                        }
//                    }
//
//
//                }
                if(!showFlag)
                {
                    return false;
                }
                getMenuInflater().inflate(R.menu.menu_project_detail_zqr, menu);

            }catch (Exception ex)
            {
                ex.printStackTrace();
            }

        }


        return super.onPrepareOptionsMenu(menu);
    }



    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        if(id == android.R.id.home)
        {
            finish();
        }
        if (id == R.id.menu_ddd) {


//            if("0".equalsIgnoreCase(mInfo.getProcessStatus().getValue()) )
//            {
//                return false;
//            }
//            if("1".equalsIgnoreCase(mInfo.getProcessStatus().getValue()) )
//            {
//
//                if("0".equalsIgnoreCase(mInfo.getIdentityStatus().getValue()) ||"2".equalsIgnoreCase(mInfo.getIdentityStatus().getValue()))
//
//                    return false;
//            }


            PopupMenuPublicPro popupMenu;
            popupMenu = new PopupMenuPublicPro(this);
            if (mInfo.getAuth() != null) {

//                666


                ArrayList<String> ary = new ArrayList<String>();

//                if(!"1".equalsIgnoreCase(mInfo.getProcessStatus().getValue()) ) {
                    if (mInfo.getAuth().isInputCreditor()) {
                        ary.add("录入基础信息");
                    }
//                }else {
//
//                    if ("6".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
//
//                            ary.add("录入基础信息");
//
//                    }
//                }

//                if(!"0".equalsIgnoreCase(mInfo.getProcessStatus().getValue()) ) {

//                    if (!"6".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {

                        if (mInfo.getAuth().isEditCreditorBasicInfo()) {
                            ary.add("修改基础信息");
                        }
                        if (mInfo.getAuth().isEditBasicInfo()) {
                            ary.add("修改基础信息");
                        }
//
//                    }
//
//                }
//                if () {
//                    ary.add("修改基础信息");
//                }
                if (mInfo.getAuth().isChangeCreditor()) {
                    ary.add("变更债权人");
                }
                if (mInfo.getAuth().isChangeToLegalRepresentativeOperation()) {
                    ary.add("变更为法定代表人操作");
                }
                if (mInfo.getAuth().isChangeToNewLegalRepresentative()) {
                    ary.add("变更为新的法定代表人操作");
                }

                if (mInfo.getAuth().isChangeToMyOperation()) {
                    ary.add("变更为本人操作");
                }
                if (mInfo.getAuth().isNewAgent()) {
                    ary.add("新增代理人");
                }
                if(mInfo.getAuth().isEntryDeclarationInformation()) {
                    ary.add("录入申报");
                }
                if (mInfo.getAuth().isChangeToOnline()) {
                    ary.add("转为线上债权人");
                }
                if (mInfo.getAuth().isChangeToOffline()) {
                    ary.add("转为线下债权人");
                }
                if (mInfo.getAuth().isOnCommittee()) {
                    ary.add("设为债委会成员");
                }
                if (mInfo.getAuth().isOffCommittee()) {
                    ary.add("卸任债委会成员");
                }
                if (mInfo.getAuth().isOnCommitteeChairman()) {
                    ary.add("设为债权人会议主席");
                }
                if (mInfo.getAuth().isOffCommitteeChairman()) {
                    ary.add("卸任债权人会议主席");
                }
                if(mInfo.getAuth().isEnterSupplementaryDeclarationInformation()) {
                    ary.add("录入补充申报");
                }
                if(mInfo.getAuth().isInputObjectionInformation()) {
                    ary.add("录入异议信息");
                }





                if (ary.size() > 0) {
                    popupMenu.initData(ary);
                } else {
                    findViewById(R.id.menu_ddd).setVisibility(View.INVISIBLE);
                    return false;
                }

            } else {
                findViewById(R.id.menu_ddd).setVisibility(View.INVISIBLE);
                return false;
            }


            popupMenu.showLocation(R.id.menu_ddd);// 设置弹出菜单弹出的位置


            // 设置回调监听，获取点击事件
            popupMenu.setOnItemClickListener(new PopupMenuPublicPro.OnItemClickListener() {

                @Override
                public void onClick(PopupMenuPublicPro.MENUITEM item, String str) {
                    // TODO Auto-generated method stub
//                            changeType=1;
                    //修改基础信息", "变更债权人", "变更为法定代表人", "变更为自然人操作", "录入申报信息 新增代理人
                    if ("录入基础信息".equalsIgnoreCase(str)) {
                        //录入完整功能
                        ZQUserDetailBaseInfo info = new ZQUserDetailBaseInfo();
                        info.setId(mInfo.getId());
                        if("".equalsIgnoreCase(mInfo.getContact()))
                        {
                            com.linkage.jz.bankruptcy.net.ToastUtil.showShort("您还没有手机号码，请先进行设置");
                            return;
                        }
//                        info.setContact(mInfo.getContact());
//                        info.setBankruptcyProjectId(mInfo.getBankruptcyProjectId());
                        getTempData(mInfo.getContact());
//                        EditZQUserBaseInfoActivity.start(ZQUserDetailActivity.this, info, 0, 0);
                    }
                    else if ("修改基础信息".equalsIgnoreCase(str)) {


                        if ("7".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {

                            //可以切换类型，但是展示有不一样
                            EditZQUserBaseInfo_EditActivity.start(ZQUserDetailActivity.this, mInfo, 0, 1);
                        }else{
                            //不可以修改类型，只能修改几个部分信息
                            EditZQUserBaseInfo_ChangeActivity.start(ZQUserDetailActivity.this, mInfo, 0, 1);

                        }
                    } else if ("变更债权人".equalsIgnoreCase(str)) {
//                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
//                            @Override
//                            public void onClick(View v) {
//                                if (v.getId() == R.id.btn_save_notice) {

                                    ZQUserDetailBaseInfo info = new ZQUserDetailBaseInfo();
                                    info.setId(mInfo.getId());
                                    info.setBankruptcyProjectId(mInfo.getBankruptcyProjectId());
                                    ChangeZQUserBaseNewInfoActivity.start(ZQUserDetailActivity.this, mInfo, 0, 1);
//                                }
//                                noticeDialog.dismiss();
//                            }
//                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
//                                "暂未取得", "已取得");
//                        noticeDialog.show();
                    } else if ("变更为法定代表人操作".equalsIgnoreCase(str)) {

                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    ZQUserDetailBaseInfo info = new ZQUserDetailBaseInfo();

                                    info.setBankruptcyProjectId(mInfo.getBankruptcyProjectId());
                                    info.setId(mInfo.getId());
                                    if("0".equalsIgnoreCase(mInfo.getIdentitySmallTypes().getValue())) {
                                        ChangerLegalRepActivity.start(ZQUserDetailActivity.this, info, "0", 0, 2);
                                    }else{
                                        ChangerLegalRepActivity.start(ZQUserDetailActivity.this, info, "0", 0, 1);
                                    }
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
                                "暂未取得", "已取得");
                        noticeDialog.show();


                    } else if ("变更为本人操作".equalsIgnoreCase(str)) {
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    ZQUserDetailBaseInfo info = new ZQUserDetailBaseInfo();
                                    info.setBankruptcyProjectId(mInfo.getBankruptcyProjectId());
                                    info.setId(mInfo.getId());
                                    info.setCreditorName(mInfo.getCreditorName());
                                    info.setAddressInfo(mInfo.getAddressInfo());
                                    ChangeToMeActivity.start(ZQUserDetailActivity.this, info, creditorId, "0", 0);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
                                "暂未取得", "已取得");
                        noticeDialog.show();

                    } else if ("录入申报".equalsIgnoreCase(str)) {

                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
//                                    AddProxyUserActivity.start(ZQUserDetailActivity.this, proid, creditorId, 0, 0);
//                                    jumpEditInfoPage();
//                                    CreateZQFristApplyActivity.start(ZQUserDetailActivity.this, creditorId, mInfo.getBankruptcyProjectId(), mInfo.getIdentityBigTypes().getValue(), 0);
                                    String bigtype = mInfo.getIdentityBigTypes().getValue();// 0表示企业，1表示自然债权人，2标识税务机关

                                    CreateZQFristApplyActivity.start(ZQUserDetailActivity.this, mInfo.getId(), mInfo.getBankruptcyProjectId(), bigtype, 0);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
                                "暂未取得", "已取得");
                        noticeDialog.show();

                    } else if ("新增代理人".equalsIgnoreCase(str)) {
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    AddProxyUserActivity.start(ZQUserDetailActivity.this, proid, creditorId, 0, 0);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
                                "暂未取得", "已取得");
                        noticeDialog.show();
                    } else if ("转为线下债权人".equalsIgnoreCase(str)) {
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    convertOnlineStatus(2);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "您确认该成员转为线下债权人",
                                "取消", "确认");
                        noticeDialog.show();


                    } else if ("转为线上债权人".equalsIgnoreCase(str)) {
//                        convertOnlineStatus(1);
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    convertOnlineStatus(1);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "您确认该成员转为线上债权人",
                                "取消", "确认");
                        noticeDialog.show();
                    } else if ("卸任债委会成员".equalsIgnoreCase(str)) {
//                        settingCommittee(2);
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    settingCommittee(2);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "您确认该成员卸任债委会成员",
                                "取消", "确认");
                        noticeDialog.show();
                    } else if ("设为债委会成员".equalsIgnoreCase(str)) {
//                        settingCommittee(1);
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    settingCommittee(1);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "您确认该成员设为债委会成员",
                                "取消", "确认");
                        noticeDialog.show();
                    } else if ("设为债权人会议主席".equalsIgnoreCase(str)) {
//                        settingCommittee(3);
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    settingCommittee(3);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "您确认该成员设为债权人会议主席",
                                "取消", "确认");
                        noticeDialog.show();
                    }else if ("卸任债权人会议主席".equalsIgnoreCase(str)) {
//                        settingCommittee(4);
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    settingCommittee(4);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "您确认该成员卸任债权人会议主席",
                                "取消", "确认");
                        noticeDialog.show();
                    }

                    else if ("变更为新的法定代表人操作".equalsIgnoreCase(str)) {

                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    ZQUserDetailBaseInfo info = new ZQUserDetailBaseInfo();
                                    info.setBankruptcyProjectId(mInfo.getBankruptcyProjectId());
                                    info.setId(mInfo.getId());
                                    if("0".equalsIgnoreCase(mInfo.getIdentitySmallTypes().getValue())) {
                                        ChangerLegalRepActivity.start(ZQUserDetailActivity.this, info, "0", 0, 2);
                                    }else{
                                        ChangerLegalRepActivity.start(ZQUserDetailActivity.this, info, "0", 0, 1);
                                    }
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
                                "暂未取得", "已取得");
                        noticeDialog.show();
                    }else if ("录入补充申报".equalsIgnoreCase(str)) {

                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
//

                                    getSubData("",mInfo.getBankruptcyProjectId(),1);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
                                "暂未取得", "已取得");
                        noticeDialog.show();
                    }else if ("录入异议信息".equalsIgnoreCase(str)) {

                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (v.getId() == R.id.btn_save_notice) {
                                    getSubData("",mInfo.getBankruptcyProjectId(),2);
                                }
                                noticeDialog.dismiss();
                            }
                        }, 1, "提示", "该操作须取得债权人授权或依据文件",
                                "暂未取得", "已取得");
                        noticeDialog.show();
                    }



//                    Toast.makeText(ZQUserDetailActivity.this,str,Toast.LENGTH_LONG).show();
                }
            });
        }


        return super.onOptionsItemSelected(item);
    }
    //

//    private void jumpEditInfoPage(ZQBaseInfo proZQUserZQInfo, boolean isReplenishOrReviewPage,String bigType,String mProid) {
//        Intent intent = new Intent(ZQUserDetailActivity.this, EditCreditorReviewInfoActivity.class);
//        intent.putExtra(EditCreditorReviewInfoActivity.INTENT_IS_TAX_MODE, "2".equalsIgnoreCase(bigType));//true：税务，false： //非税务
//        intent.putExtra(EditCreditorReviewInfoActivity.INTENT_IS_REPLENISH_REVIEW, isReplenishOrReviewPage);//true:补充 类型
//        intent.putExtra(EditCreditorReviewInfoActivity.INTENT_ID_PROJECT, mProid);
//        String crReviewId = proZQUserZQInfo.getCrReviewId();
//        if ("".equalsIgnoreCase(crReviewId)) {
//            if (proZQUserZQInfo != null && proZQUserZQInfo.getProjectCrDec() != null && proZQUserZQInfo.getProjectCrDec().getPreVersion() != null&& proZQUserZQInfo.getProjectCrDec().getPreVersion().getReview()!=null) {
//                crReviewId = proZQUserZQInfo.getProjectCrDec().getPreVersion().getReview().getId();
//            }
//        }
//        intent.putExtra(EditCreditorReviewInfoActivity.INTENT_ID_REVIEW, crReviewId);
//        intent.putExtra(EditCreditorReviewInfoActivity.INTENT_ID_CREDITOR_RIGHTS, proZQUserZQInfo.getCreditorRightsId());
//        startActivity(intent);
//    }

    /**
     * 设置屏幕透明度
     *
     * @param alpha
     */
    private void setWindowAlpha(float alpha) {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
//        lp.alpha = alpha; //0.0-1.0
//       getWindow().setAttributes(lp);
    }


    public int Dp2Dx(Context context, float dp) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }


    private  int page ;
    private CreateZQUserNoticeDialog createZQUserNoticeDialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //当系统版本为4.4或者4.4以上时可以使用沉浸式状态栏
        super.onCreate(savedInstanceState);
        setStatusBarMode(false);
        showFlag = true;
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//            //透明状态栏
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            //透明导航栏
//            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
//        }
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }

        setContentView(R.layout.activity_zquser_detail);
        shapeLoadingDialog = new ShapeLoadingDialog(this);
        creditorId = getIntent().getStringExtra("creditorId");

//        mInfo=new Gson().fromJson(bookJson,ZQUserInfo.class);
        proid = getIntent().getStringExtra("proid");

         page = getIntent().getIntExtra("page",0);

//        getData(1, creditorId);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
        tv_item_bgaswipe_title1 = findViewById(R.id.tv_item_bgaswipe_title1);
        tv_item_bgaswipe_title2 = findViewById(R.id.tv_item_bgaswipe_title2);
        ll_item_bgaswipe_title4 = findViewById(R.id.ll_item_bgaswipe_title4);
        tv_tag1 = findViewById(R.id.tv_tag1);
        tv_tag2 = findViewById(R.id.tv_tag2);
        tv_tag3 = findViewById(R.id.tv_tag3);
        tv_china = findViewById(R.id.tv_china);

        iv_phone= findViewById(R.id.iv_phone);
        iv_email= findViewById(R.id.iv_email);

        iv_phone.setVisibility(View.VISIBLE);
        iv_email.setVisibility(View.VISIBLE);

        getUnread();
        iv_email.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if(mInfo!=null) {
                    if(mInfo.getAuth()!=null )
                    {
//                mAuthBaseInfo
                        if(!mInfo.getAuth().isContactCreditor())
                        {
                            com.linkage.jz.bankruptcy.net.ToastUtil.showShort("您没有权限操作");
                            return;
                        }
                    }

                    if (mInfo.getId() != null)
                        ChatDetailActivity.start(ZQUserDetailActivity.this, mInfo.getId(),
                                mInfo.getCreditorName(), mInfo.getBankruptcyProjectId());
                }
            }
        });

        iv_phone.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if(mInfo!=null) {


                    if (mInfo != null || !TextUtils.isEmpty(mInfo.getContact())) {

                        if(mInfo.getAuth()!=null )
                        {
//                mAuthBaseInfo
                            if(!mInfo.getAuth().isContactCreditor())
                            {
                                com.linkage.jz.bankruptcy.net.ToastUtil.showShort("您没有权限操作");
                                return;
                            }
                        }
                        final String phone = mInfo.getContact();
                        SetPhone(phone);
                        noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener(){

                            @Override
                            public void onClick(View v) {
                                switch (v.getId()) {
                                    case R.id.ll_close:
                                        noticeDialog.dismiss();
                                        break;
                                    case R.id.btn_chancel_notice:

                                        if(checkReadPermission(Manifest.permission.CALL_PHONE,REQUEST_SMS_PERMISSION)){

                                            try {
//                    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(phone));

                                                Intent intent = new Intent(Intent.ACTION_SENDTO);
                                                Uri data = Uri.parse("smsto:" + phone);
                                                intent.setData(data);
                                                startActivity(intent);

//                                                Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:"+phoneNumber));
//                                                intent.putExtra("sms_body", message);
//                                                startActivity(intent);

                                            }catch (Exception ex){
                                                ex.printStackTrace();
                                            }
                                        }
                                        noticeDialog.dismiss();
                                        break;

                                    case R.id.btn_save_notice:
                                        if(!"".equalsIgnoreCase(phone)) {
                                            if(checkReadPermission(Manifest.permission.CALL_PHONE,REQUEST_CALL_PERMISSION)){

                                                try {
//                    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(phone));

                                                    Intent intent = new Intent(Intent.ACTION_CALL);
                                                    Uri data = Uri.parse("tel:" + phone);
                                                    intent.setData(data);
                                                    startActivity(intent);
                                                }catch (Exception ex){
                                                    ex.printStackTrace();
                                                }
                                            }
                                        }
                                        noticeDialog.dismiss();

                                        break;
                                }
                            }
                        }, 2,phone, phone,"发短信","拨打电话");
                        noticeDialog.show();
                    } else
                        showToast("无法获取号码");
                }
            }
        });


        ll_tag = findViewById(R.id.ll_tag);
        tabLayout = (TabLayout) findViewById(R.id.tabLayout);
        appbar = (AppBarLayout) findViewById(R.id.appbar);
        viewpager = (ViewPager) findViewById(R.id.viewpager);

        sendmsg = findViewById(R.id.sendmsg);
        tv_user_status = (TextView) findViewById(R.id.tv_user_status);
        tv_send_notice = (TextView) findViewById(R.id.tv_send_notice);
        tv_online = (TextView) findViewById(R.id.tv_online);
        sendmsg = findViewById(R.id.sendmsg);
        tv_username = (TextView) findViewById(R.id.tv_username);


//        tv_manageuser = (TextView) findViewById(R.id.tv_manageuser);
//        iv_proimg = (ImageView)findViewById(R.id.iv_proimg);

//        LinearLayout pro_detail_managerterm = (LinearLayout)findViewById(R.id.pro_detail_managerterm);
        tv_send_notice.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if(mInfo!=null) {


                    if ("0".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
                        name = mInfo.getCreditorName();
                        phone =  mInfo.getContact();
//                        if ("0".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                            createZQUserNoticeDialog = new CreateZQUserNoticeDialog(ZQUserDetailActivity.this, onClickListener, name, phone);
                            createZQUserNoticeDialog.show();
//                        }  else if ("1".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
//                            createZQUserNoticeDialog = new CreateZQUserNoticeDialog(ZQUserDetailActivity.this, onClickListener, "11", "11");
//                            createZQUserNoticeDialog.show();
//                        }


                    }

                    if(mInfo.getIdentityStatus()!=null) {
                        if ("2".equalsIgnoreCase(mInfo.getIdentityStatus().getValue())) {
                            noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    String sendStatus = "";
                                    if (view.getId() == R.id.btn_chancel_notice) {//暂存

                                        noticeDialog.dismiss();
                                    } else if (view.getId() == R.id.ll_close) {
                                        noticeDialog.dismiss();
                                        return;
                                    } else {//生成

                                        noticeDialog.dismiss();
                                    }
                                    noticeDialog.dismiss();

                                }
                            }, 5, "原因", mInfo.getAuditInstructions(), "", "确定");
                            noticeDialog.show();
                        }
                    }
                }
            }
        });


        popClick = findViewById(R.id.pop_click);
        /**
         * 弹窗
         */
        popClick.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                QuickPopView.show(ZQUserDetailActivity.this);
            }
        });

        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);

        //2.MODE_FIXED模式
//        tabLayout.setTabMode(TabLayout.MODE_FIXED);


//        setTitle("");
        collapsingToolbar.setTitle("");
        collapsingToolbar.setExpandedTitleColor(Color.parseColor("#00ffffff"));//设置还没收缩时状态下字体颜色
        collapsingToolbar.setCollapsedTitleTextColor(Color.WHITE);//设置收缩后Toolbar上字体的
        adapter = new CommonTabPagerAdapter(getSupportFragmentManager()
                , 3, Arrays.asList("基础信息", "债权信息", "操作记录"), this);
        adapter.setListener(this);
        viewpager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewpager);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        EventBus.getDefault().register(this);

        for (int i = 0; i <tabLayout.getTabCount() ; i++) {
            tabLayout.getTabAt(i).setCustomView(R.layout.custom_tab_pro) ;
        }
        tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                ((TextView)tab.getCustomView().findViewById(R.id.text)).setTextColor(Color.parseColor("#289F9F"));
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
                ((TextView)tab.getCustomView().findViewById(R.id.text)).setTextColor(Color.parseColor("#333333"));
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        tabLayout.getTabAt(page).select();


//        getUnread();
    }

    private void getUnread() {
        Network
                .getAPIService()
                .operationLog(getUserToken(),proid,"1","100",creditorId)
                .subscribeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
//                            super.onNext(json);
                            return;
                        }
                        String num="0";
//                        String num = json.get("count").getAsInt()+"";
//                        String num="2";
                        try{
                            num = json.getAsJsonObject("data").get("redPointCount").getAsInt()+"";
                        }catch (Exception ex){
                            ex.printStackTrace();
                        }

//                        if(data2 != null){
//                            String num = data2.get("count").getAsString();

                           String[] titles = new String[]{"基础信息", "债权信息", "操作记录"} ;
                            for (int i = 0; i <tabLayout.getTabCount() ; i++) {
                                TextView tv_text = tabLayout.getTabAt(i).getCustomView().findViewById(R.id.text);
                                TextView tv_num = tabLayout.getTabAt(i).getCustomView().findViewById(R.id.num);
                                tv_text.setText(titles[i]);
//                                if(i==0){
//                                    tv_text.setTextColor(Color.parseColor("#289F9F"));
//                                }
                                if(i==page){
                                    tv_text.setTextColor(Color.parseColor("#289F9F"));
                                }
                                // 第三个tab，且未读大于0
                                if(!"0".equals(num) && i == 2){
                                    tv_num.setVisibility(View.VISIBLE);
                                    tv_num.setText(num);
                                }else {
                                    tv_num.setVisibility(View.GONE);

                                }
                            }
                        viewpager.setCurrentItem(page);
//                        }
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                });

    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        page = intent.getIntExtra("page",0);
        viewpager.setCurrentItem(page);

        creditorId = intent.getStringExtra("creditorId");
        proid = intent.getStringExtra("proid");

        getData(1, creditorId);

    }

    private View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            switch (v.getId()) {

                case R.id.btn_chancel_zq_u:


                        createZQUserNoticeDialog.dismiss();

                    break;
                case R.id.btn_save_zq_u:

//                    String name = createZQUserNoticeDialog.text_name_zq_u.getText().toString().trim();
//                    String phone = createZQUserNoticeDialog.text_mobile_zq_u.getText().toString().trim();

                    String notifyType = "";
                    String flag = "false";
                    if (createZQUserNoticeDialog.ck_inmsg.isChecked()) {
                        notifyType = "0";
                    }

                    if (createZQUserNoticeDialog.ck_msg.isChecked()) {
                        if ("".equalsIgnoreCase(notifyType)) {
                            notifyType = "1";
                        } else {
                            notifyType = notifyType + ",1";
                        }
                    }

                    if (createZQUserNoticeDialog.ck_outmsg.isChecked()) {
                        if ("".equalsIgnoreCase(notifyType)) {
                            notifyType = "2";
                            if("".equalsIgnoreCase(phone))
                            {
                                flag = "true";
                            }
                        } else {
                            notifyType = notifyType + ",2";
                        }
                    }

                    sendNotice(notifyType);
//                    addZQUser(name, phone, notifyType,flag);
//
                    createZQUserNoticeDialog.dismiss();


                    break;

            }
        }
    };

    private void showData(ZQUserDetailBaseInfo mInfo) {
        if (mInfo != null) {



            iv_email.setVisibility(View.VISIBLE);
            iv_phone.setVisibility(View.VISIBLE);

            if (mInfo.getContact() == null || "".equalsIgnoreCase(mInfo.getContact())) {
                iv_email.setVisibility(View.INVISIBLE);
                iv_phone.setVisibility(View.INVISIBLE);

            } else {
//                viewHolderHelper.setVisibility(R.id.iv_email, View.VISIBLE);
                if(mInfo.getAuth().isContactCreditor()) {
                    iv_email.setVisibility(View.VISIBLE);
                }else{
                    iv_email.setVisibility(View.INVISIBLE);
                }
                iv_phone.setVisibility(View.VISIBLE);
                if ("2".equalsIgnoreCase(mInfo.getOnlineStatus().getValue())) {
                    iv_email.setVisibility(View.INVISIBLE);
                }
            }




            if ("5".equalsIgnoreCase(mInfo.getProcessStatus().getValue()) || "3".equalsIgnoreCase(mInfo.getProcessStatus().getValue()) || "4".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
                tv_user_status.setVisibility(View.INVISIBLE);
                tv_send_notice.setVisibility(View.INVISIBLE);

                tv_username.setText(mInfo.getCreditorName());
//                if ("1".equalsIgnoreCase(mInfo.getOnlineStatus().getValue())) {
//                    tv_online.setVisibility(View.GONE);
//
//                } else {
////                    tv_online.setVisibility(View.VISIBLE);
////                    sendmsg.setVisibility(View.VISIBLE);
////                    tv_tag.setVisibility(View.GONE);
////                    tv_item_bgaswipe_title2.setVisibility(View.GONE);
////                    tv_item_bgaswipe_title1.setVisibility(View.GONE);
//                    tv_online.setText("线下");
//                }

                if("true".equalsIgnoreCase(mInfo.getCommitteeChairman()))
                {
                    tv_china.setVisibility(View.VISIBLE);
                }else{
                    tv_china.setVisibility(View.INVISIBLE);
                }

                if(!"1".equalsIgnoreCase(mInfo.getOnlineStatus().getValue()))
                {
                    tv_item_bgaswipe_title1.setVisibility(View.INVISIBLE);
                    tv_item_bgaswipe_title2.setVisibility(View.INVISIBLE);
                    ll_item_bgaswipe_title4.setVisibility(View.GONE);
                    tv_tag1.setVisibility(View.GONE);
                    tv_tag2.setVisibility(View.GONE);
                    tv_tag3.setVisibility(View.VISIBLE);
                    tv_tag3.setText("线下");
                    sendmsg.setVisibility(View.GONE);
                }else {
                    sendmsg.setVisibility(View.VISIBLE);
                    if ("5".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
                        ll_tag.setVisibility(View.VISIBLE);
                    } else {
                        ll_tag.setVisibility(View.GONE);
                    }
                    sendmsg.setVisibility(View.GONE);
                    tv_item_bgaswipe_title1.setVisibility(View.VISIBLE);
                    tv_item_bgaswipe_title2.setVisibility(View.VISIBLE);
                    ll_item_bgaswipe_title4.setVisibility(View.VISIBLE);

                    if ("true".equalsIgnoreCase(mInfo.getKindGuarantee())) {
                        tv_tag1.setText("担保优先");
                        tv_tag1.setVisibility(View.VISIBLE);
                        tv_tag1.setBackgroundResource(R.drawable.bg_text_pro_talk_member_tag_dbyx);
                    }
                    if ("true".equalsIgnoreCase(mInfo.getKindTax())) {
                        tv_tag1.setText("税务");
                        tv_tag1.setVisibility(View.VISIBLE);
                        tv_tag1.setBackgroundResource(R.drawable.bg_text_pro_talk_member_tag_sw);

                    }
                    if ("true".equalsIgnoreCase(mInfo.getKindOther())) {
                        tv_tag2.setText("其他优先");
                        tv_tag2.setVisibility(View.VISIBLE);
                        tv_tag2.setBackgroundResource(R.drawable.bg_text_pro_talk_member_tag_qtyx);

                    }
                    if ("true".equalsIgnoreCase(mInfo.getKindOrdinary())) {
                        tv_tag3.setText("普通");
                        tv_tag3.setVisibility(View.VISIBLE);
                        tv_tag3.setBackgroundResource(R.drawable.bg_text_pro_talk_member_tag_pt);
                    }
                    DecimalFormat decimalFormat = new DecimalFormat("0.00");//构造方法的字符格式这里如果小数不足2位,会以0补足.
                    if (mInfo.getAmountDeclared() != null) {

                        float f = Float.parseFloat(mInfo.getAmountDeclared());

                        String p = decimalFormat.format(f);
                        tv_item_bgaswipe_title1.setText("申报金额：" + CommonUtils.resetMoney(mInfo.getAmountDeclared()) + "元");

                        if (mInfo.getConfirmAmount() != null) {
                            ll_item_bgaswipe_title4.setVisibility(View.VISIBLE);
                            f = Float.parseFloat(mInfo.getConfirmAmount());


                            p = decimalFormat.format(f);

                            tv_item_bgaswipe_title2.setText(CommonUtils.resetMoney(mInfo.getConfirmAmount()) + "");
                            if (!mInfo.getAmountDeclared().equalsIgnoreCase(mInfo.getConfirmAmount())) {
                                tv_item_bgaswipe_title2.setTextColor(getResources().getColor(R.color.page_top));
                            }
                        } else {
                            ll_item_bgaswipe_title4.setVisibility(View.GONE);
                        }
                    } else {
                        tv_item_bgaswipe_title1.setText("");
                    }
                }

            } else {

                if ("0".equalsIgnoreCase(mInfo.getOnlineStatus().getValue())) {
                    tv_online.setText("线上");
                } else {
                    tv_online.setText("线下");
                }
                tv_username.setText(mInfo.getCreditorName());

                //getSubStatus = 3 未邮寄通知 1未通知 0 已通知

                if (!"2".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
                    if ("0".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
                        if ("0".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                            tv_user_status.setText("已通知");
                            if(mInfo.getAuth().isAgainNotice()) {
                                tv_send_notice.setVisibility(View.VISIBLE);
                            }else{
                                tv_send_notice.setVisibility(View.INVISIBLE);
                            }
                            tv_send_notice.setText("  再次通知  ");

                        } else if ("2".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                            tv_user_status.setText("已邮寄通知");
                            tv_send_notice.setVisibility(View.INVISIBLE);
                            tv_send_notice.setText("  发送通知  ");
                                iv_email.setVisibility(View.INVISIBLE);

                        } else if ("3".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                            tv_user_status.setText("邮寄通知");
                            if(mInfo.getAuth().isMailNotice())
                            {
                                tv_user_status.setVisibility(View.VISIBLE);
                            }else{
                                tv_user_status.setVisibility(View.INVISIBLE);
                            }
                            tv_user_status.setTextColor(getResources().getColor(R.color.page_top));
                            tv_user_status.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View view) {
                                    noticeDialog = new PublicNoticeDialog(ZQUserDetailActivity.this, new View.OnClickListener() {
                                        @Override
                                        public void onClick(View view) {
                                            String sendStatus = "";
                                            if (view.getId() == R.id.btn_chancel_notice) {//暂存
                                                sendStatus = "1";
                                                noticeDialog.dismiss();
                                            } else if (view.getId() == R.id.ll_close) {
                                                if (noticeDialog != null && noticeDialog.isShowing())
                                                    noticeDialog.dismiss();
                                                return;
                                            } else {//生成
                                                sendStatus = "2";
                                                noticeDialog.dismiss();
                                                mailNoticeDone(creditorId);
                                            }
//                    saveData(sendStatus);
                                            noticeDialog.dismiss();

                                        }
                                    }, 1, "提示", "是否已邮寄通知该债权人？", "取消", "已通知");
                                    noticeDialog.show();
                                }
                            });

                            tv_send_notice.setVisibility(View.INVISIBLE);


                        } else if ("1".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                            tv_user_status.setText("未通知");
                            tv_send_notice.setText("  发送通知  ");
//                            tv_send_notice.setVisibility(View.VISIBLE);
                            if(mInfo.getAuth().isAddCreditor()) {
                                tv_send_notice.setVisibility(View.VISIBLE);
                            }else{
                                tv_send_notice.setVisibility(View.INVISIBLE);
                            }
                        } else if ("4".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                            tv_user_status.setText("已拒绝");
                            tv_send_notice.setText("  发送通知  ");
                            tv_send_notice.setVisibility(View.VISIBLE);
                        } else {
                            tv_send_notice.setVisibility(View.INVISIBLE);
                        }
                    } else if ("1".equalsIgnoreCase(mInfo.getProcessStatus().getValue())) {
                        tv_send_notice.setVisibility(View.GONE);

//                        if("0".equalsIgnoreCase(mInfo.getDataStatus().getValue()))
//                        {
//                            if ("0".equalsIgnoreCase(mInfo.getIdentityStatus().getValue())) {
//                                tv_user_status.setText("身份待验证");
//
//                            } else if ("1".equalsIgnoreCase(mInfo.getIdentityStatus().getValue())) {
//                                tv_user_status.setText("已接收邀请");
//
//                            } else if ("2".equalsIgnoreCase(mInfo.getIdentityStatus().getValue())) {
//                                tv_user_status.setText("身份验证不通过");
//                                tv_send_notice.setText("  查看原因  ");
//                                tv_send_notice.setVisibility(View.VISIBLE);
//                            }
//                        }else{
                        if ("7".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
//                            tv_user_status.setText("已拒绝身份");
                            tv_user_status.setText("身份验证不通过");
                            tv_send_notice.setText("  查看原因  ");
                            if(mInfo.getAuth().isAuditCreditor()) {
                                tv_send_notice.setVisibility(View.VISIBLE);
                            }else{
                                tv_send_notice.setVisibility(View.INVISIBLE);
                            }
//                            tv_send_notice.setVisibility(View.VISIBLE);
                        }else if ("6".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                                tv_user_status.setText("已接收邀请");
                            }else if ("5".equalsIgnoreCase(mInfo.getSubStatus().getValue())) {
                                tv_user_status.setText("身份待验证");
                            }


//                        }

                    } else {
                        tv_send_notice.setVisibility(View.GONE);
                    }
                } else {
                    tv_send_notice.setVisibility(View.GONE);
                    tv_user_status.setVisibility(View.GONE);
                }


            }
            supportInvalidateOptionsMenu();
//            if (mInfo.getOpStatus() != null) {
//
//            }
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        //在界面销毁的地方要解绑
        EventBus.getDefault().unregister(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        getData(1,creditorId);
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(RefreshEvent event) {
        if (TextUtils.equals(event.getType(), RefreshEvent.FLASHZQUSERDETAIL)) {
            getData(1,creditorId);
        }
    }
//    @Subscribe
//    public void getEventBus(MyProInfo info) {
//        if (info != null) {
////            mInfo = info;
////            adapter.notifyDataSetChanged();
////            if(mInfo!=null)
////            {
////                tv_proname.setText(mInfo.getProjectName());
////                tv_manageaddr.setText(mInfo.getManagerListStr());
////                tv_manageuser.setText(mInfo.getDebtorLegalRepresentative());
////
////                String url = mInfo.getProjectLogo();
////
////                Glide.with(this).load(url)
////                        .bitmapTransform(new CropCircleTransformation(this))
////                        .placeholder(R.drawable.avatar_defult)
////                        .into(iv_proimg);
////            }
//            //这里拿到事件之后吐司一下
//            //            Toast.makeText(getActivity(), "num" + num, Toast.LENGTH_SHORT).show();
//        }
//    }

    @Override
    public Fragment getFragment(int position) {
        switch (position) {
            case 0:
                return ZQUserBaseDetailFragment.newInstance(position, creditorId, proid);
            case 1:
                return ZQUserZQBaseDetailFragment.newInstance(position, creditorId, proid, this);
            case 2:
//                return ProZQFragment.newInstance(position,mInfo.getId(),mInfo);
//                break;
                return ZQUserOperateBaseFragment.newInstance(position, creditorId, proid);
//            case 3:
//                return ZQUserOperateBaseFragment.newInstance(position,creditorId,proid);

//            case 4:
//                return ProTalkFragment.newInstance(position,mInfo.getId());
//            case 5:
//                return ProTaskFragment.newInstance(position,mInfo.getId());
//            case 6:
//                return ProPublicFragment.newInstance(position,mInfo.getId());
            default:
                return ZQUserOperateBaseFragment.newInstance(position, creditorId, proid);

//
//                    return ProFlowFragment.newInstance(position,mInfo.getId());
//                    break;
        }

    }



    public void sendNotice(String sendtype) {


        if (BankruptcyApp.tokeninfo == null || BankruptcyApp.tokeninfo.getToken() == null) {
//            getToken();
            return;
        }

        OkHttpClient okHttpClient = new OkHttpClient();
        HashMap<String, String> params = new HashMap<String, String>();
        Random random = new Random();
        String rom = random.nextLong() + "";
        String timestamp = System.currentTimeMillis() + "";


        String sign = SignUtil.createSign(Consts.APPKEY, params);
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");

        RequestBody requestBody = new FormBody.Builder()
                .add("appid", "1000000001")
                .add("nonce", rom)
                .add("timestamp", timestamp)
                .add("token", BankruptcyApp.tokeninfo.getToken())
                .add("userToken", userToken)

                .add("projectId", proid)
                .add("creditorId", creditorId)
                .add("notifyTypes", sendtype)
                .build();

        String url = Consts.WEBURL_SENDNOTICE;

        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
//                Log.d(TAG, "onFailure: " + e.getMessage());
//                shapeLoadingDialog.dismiss();
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
//                Log.d(TAG, response.protocol() + " " +response.code() + " " + response.message());
                Headers headers = response.headers();


//                shapeLoadingDialog.dismiss();
                String str = response.body().string();
                try {
                    JSONObject object = new JSONObject(str);
                    if (object.optInt("code") == 0) {

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                Toast.makeText(ZQUserDetailActivity.this,
                                        "提交成功", Toast.LENGTH_SHORT).show();
//                                finish();

                            }

                        });
                    } else {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                Toast.makeText(ZQUserDetailActivity.this,
                                        "提交失败", Toast.LENGTH_SHORT).show();


                            }

                        });
                    }

                    str = "";
                } catch (Exception ex) {

                    ex.printStackTrace();
                }
            }
        });


    }

    public void getData(int type, String data) {
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");

        Network
                .getAPIService()
                .creditorInfo(userToken, proid, data, 0)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            super.onNext(json);
                            return;
                        }
                        JsonObject data = json.getAsJsonObject("data");
                        mInfo = new Gson().fromJson(data.getAsJsonObject("creditorInfo"), ZQUserDetailBaseInfo.class);
                        mInfo.setOpStatus(data.get("opStatus").getAsString());
                        ZQUserDetailAuthBaseInfo authBaseInfo = new Gson().fromJson(data.getAsJsonObject("auth"), ZQUserDetailAuthBaseInfo.class);
                        mInfo.setAuth(authBaseInfo);


                        if (authBaseInfo != null) {

//                666


                            ArrayList<String> ary = new ArrayList<String>();

                                if (authBaseInfo.isInputCreditor()) {
                                    ary.add("录入基础信息");
                                }



                                    if (authBaseInfo.isEditCreditorBasicInfo()) {
                                        ary.add("修改基础信息");
                                    }
                                    if (authBaseInfo.isEditBasicInfo()) {
                                        ary.add("修改基础信息");
                                    }

                            if (authBaseInfo.isChangeCreditor()) {
                                ary.add("变更债权人");
                            }
                            if (authBaseInfo.isChangeToLegalRepresentativeOperation()) {
                                ary.add("变更为法定代表人操作");
                            }
                            if (authBaseInfo.isChangeToNewLegalRepresentative()) {
                                ary.add("变更为新的法定代表人操作");
                            }

                            if (authBaseInfo.isChangeToMyOperation()) {
                                ary.add("变更为本人操作");
                            }
                            if (authBaseInfo.isNewAgent()) {
                                ary.add("新增代理人");
                            }
//                if(mInfo.getAuth().isEnterSupplementaryDeclarationInformation()) {
//                    ary.add("录入补充申报信息");
//                }
//                if(mInfo.getAuth().isInputObjectionInformation()) {
//                    ary.add("录入异议信息");
//                }
                            if(authBaseInfo.isEntryDeclarationInformation()) {
                                ary.add("录入申报");
                            }
                            if(authBaseInfo.isEnterSupplementaryDeclarationInformation()) {
                                ary.add("录入补充申报");
                            }
                            if(authBaseInfo.isInputObjectionInformation()) {
                                ary.add("录入异议信息");
                            }
                            if (authBaseInfo.isChangeToOnline()) {
                                ary.add("转为线上债权人");
                            }
                            if (authBaseInfo.isChangeToOffline()) {
                                ary.add("转为线下债权人");
                            }
                            if (authBaseInfo.isOnCommittee()) {
                                ary.add("设为债委会成员");
                            }
                            if (authBaseInfo.isOffCommittee()) {
                                ary.add("卸任债委会成员");
                            }
                            if (authBaseInfo.isOnCommitteeChairman()) {
                                ary.add("设为债权人会议主席");
                            }
                            if (authBaseInfo.isOffCommitteeChairman()) {
                                ary.add("卸任债权人会议主席");
                            }






                            if (ary.size() > 0) {
                                showFlag = true;
//                                popupMenu.initData(ary);
//                                findViewById(R.id.menu_ddd).setVisibility(View.VISIBLE);
                            } else {
                                showFlag = false;
//                                findViewById(R.id.menu_ddd).setVisibility(View.INVISIBLE);
//                                return false;
                            }
                            showData(mInfo);
                        }
                    }

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                    }
                });
    }


    /**
     * 1:转为线上债权人, 2:转为线下债权人
     *
     * @param type
     */
    public void convertOnlineStatus(int type) {
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        Network
                .getAPIService()
                .convertOnlineStatus(userToken, proid, creditorId, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            showToast("设置失败");
                            super.onNext(json);
                            return;
                        } else {
                            showToast("设置成功", ToastUtil.TOAST_TYPE.SUCCESS);
                            getData(1, creditorId);
                        }
                    }

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        showToast("设置失败");
                    }
                });
    }

    /**
     * 1: 设为债委会成员 2:卸任债委会成员,3:设为债权人委员主席
     *
     * @param type
     */
    public void settingCommittee(int type) {
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        Network
                .getAPIService()
                .settingCommittee(userToken, proid, creditorId, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            showToast("设置失败");
                            super.onNext(json);
                            return;
                        } else {
                            showToast("设置成功", ToastUtil.TOAST_TYPE.SUCCESS);
                            getData(1, creditorId);
                        }
                    }

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        showToast("设置失败");
                    }
                });
    }

    public void mailNoticeDone()
    {
        if(BankruptcyApp.tokeninfo == null|| BankruptcyApp.tokeninfo.getToken() == null)
        {
            return;
        }
//        shapeLoadingDialog.setLoadingText("加载中...");
//        shapeLoadingDialog.setCanceledOnTouchOutside(false);
//        shapeLoadingDialog.show();
        OkHttpClient okHttpClient = new OkHttpClient();
//        HashMap<String, String> params = new HashMap<String, String>();
        Random random = new Random();
        String rom = random.nextLong()+"";
        String timestamp =System.currentTimeMillis()+"";
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken","");
        String userId = SPUtils.getInstance(Consts.SPNAME).getString("userId","");

        RequestBody requestBody = new FormBody.Builder()
                .add("appid","1000000001")
                .add("nonce",rom)
                .add("timestamp", timestamp)
                .add("token", BankruptcyApp.tokeninfo.getToken())
                .add("userToken",userToken)


                .add("projectId",proid)
                .add("creditorId", mInfo.getId())
                .build();

        String url = Consts.WEBURL_MAILNOTICEDONE;
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
//                shapeLoadingDialog.dismiss();
//                Log.d(TAG, "onFailure: " + e.getMessage());
                runOnUiThread(new Runnable(){

                    @Override
                    public void run() {
                        //更新UI
                        Toast.makeText(ZQUserDetailActivity.this,"保存失败",Toast.LENGTH_SHORT).show();

                    }

                });
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
//                Log.d(TAG, response.protocol() + " " +response.code() + " " + response.message());
                Headers headers = response.headers();
//                shapeLoadingDialog.dismiss();


                String str = response.body().string();
                try{
                    JSONObject object = new JSONObject(str);

                    if  (object.optInt("code") == -10004 || (object.optInt("code") == -10003))
                    {

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                LoginNoticeDialog.showPage(object.optString("msg"));
                            }

                        });

                        return;
                    }
                    if(object.optInt("code") == 0)
                    {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                Toast.makeText( ZQUserDetailActivity.this,"保存成功", Toast.LENGTH_SHORT).show();
                                getData(1,creditorId);
                            }

                        });
//                        finish();

                    }else {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                Toast.makeText(ZQUserDetailActivity.this, "保存失败"+object.optString("msg"), Toast.LENGTH_SHORT).show();

                            }

                        });

                    }
                    str = "";
                }catch (Exception ex)
                {
                    ex.printStackTrace();
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            //更新UI
                            Toast.makeText(ZQUserDetailActivity.this, "保存失败", Toast.LENGTH_SHORT).show();

                        }

                    });
                }
            }
        });
    }


    public void addZQUser(String name, String phone, String notiytype,String mailed) {
        if (BankruptcyApp.tokeninfo == null || BankruptcyApp.tokeninfo.getToken() == null) {
            return;
        }
        shapeLoadingDialog.setLoadingText("加载中...");
        shapeLoadingDialog.setCanceledOnTouchOutside(false);
        shapeLoadingDialog.show();
        OkHttpClient okHttpClient = new OkHttpClient();
//        HashMap<String, String> params = new HashMap<String, String>();
        Random random = new Random();
        String rom = random.nextLong() + "";
        String timestamp = System.currentTimeMillis() + "";
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        String userId = SPUtils.getInstance(Consts.SPNAME).getString("userId", "");


        FormBody.Builder builder = new FormBody.Builder();

        builder.add("appid", "1000000001");
        builder.add("nonce", rom);
        builder.add("timestamp", timestamp);
        builder.add("token", BankruptcyApp.tokeninfo.getToken());
        builder.add("userToken", userToken);
        builder.add("projectId", mInfo.getBankruptcyProjectId());
        builder.add("creditorName", name);
        builder.add("mobile", phone);
        if(!"".equalsIgnoreCase(notiytype)) {
            builder.add("notifyType", notiytype);
        }
        if(!"".equalsIgnoreCase(mailed)) {
            builder.add("mailed", mailed);
        }


        RequestBody requestBody = builder.build();



        String url = Consts.WEBURL_ADDCREDITOR;
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                shapeLoadingDialog.dismiss();
                Log.d(TAG, "onFailure: " + e.getMessage());
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        //更新UI
                        Toast.makeText(ZQUserDetailActivity.this, "保存失败", Toast.LENGTH_SHORT).show();

                    }

                });
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                Log.d(TAG, response.protocol() + " " + response.code() + " " + response.message());
                Headers headers = response.headers();
                shapeLoadingDialog.dismiss();
                for (int i = 0; i < headers.size(); i++) {
                    Log.d(TAG, headers.name(i) + ":" + headers.value(i));
                }


                String str = response.body().string();
                try {
                    final JSONObject object = new JSONObject(str);
                    if (object.optInt("code") == 0) {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                RefreshEvent event = new RefreshEvent();
                                event.setType(RefreshEvent.TYPE_ZQUSRE_LIST);
                                EventBus.getDefault().post(event);
                                Toast.makeText(ZQUserDetailActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
                                createZQUserNoticeDialog.dismiss();
                            }

                        });
//                        finish();

                    } else {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                Toast.makeText(ZQUserDetailActivity.this, "保存失败" + object.optString("msg"), Toast.LENGTH_SHORT).show();

                            }

                        });

                    }
                    str = "";
                } catch (Exception ex) {
                    ex.printStackTrace();
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            //更新UI
                            Toast.makeText(ZQUserDetailActivity.this, "保存失败", Toast.LENGTH_SHORT).show();

                        }

                    });
                }
            }
        });
    }


    public void mailNoticeDone(String creditorId) {
        if (BankruptcyApp.tokeninfo == null || BankruptcyApp.tokeninfo.getToken() == null) {
            return;
        }
        shapeLoadingDialog.setLoadingText("加载中...");
        shapeLoadingDialog.setCanceledOnTouchOutside(false);
        shapeLoadingDialog.show();
        OkHttpClient okHttpClient = new OkHttpClient();
//        HashMap<String, String> params = new HashMap<String, String>();
        Random random = new Random();
        String rom = random.nextLong() + "";
        String timestamp = System.currentTimeMillis() + "";
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        String userId = SPUtils.getInstance(Consts.SPNAME).getString("userId", "");

        RequestBody requestBody = new FormBody.Builder()
                .add("appid", "1000000001")
                .add("nonce", rom)
                .add("timestamp", timestamp)
                .add("token", BankruptcyApp.tokeninfo.getToken())
                .add("userToken", userToken)


                .add("projectId", mInfo.getBankruptcyProjectId())
                .add("creditorId", creditorId)
                .build();

        String url = Consts.WEBURL_MAILNOTICEDONE;
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                shapeLoadingDialog.dismiss();
                Log.d(TAG, "onFailure: " + e.getMessage());
                runOnUiThread(new Runnable() {

                    @Override
                    public void run() {
                        //更新UI
                        Toast.makeText(ZQUserDetailActivity.this, "保存失败", Toast.LENGTH_SHORT).show();

                    }

                });
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                Log.d(TAG, response.protocol() + " " + response.code() + " " + response.message());
                Headers headers = response.headers();
                shapeLoadingDialog.dismiss();
                for (int i = 0; i < headers.size(); i++) {
                    Log.d(TAG, headers.name(i) + ":" + headers.value(i));
                }


                String str = response.body().string();
                try {
                    JSONObject object = new JSONObject(str);

                    if (object.optInt("code") == 0) {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                Toast.makeText(ZQUserDetailActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
                                getData(1, creditorId);
                            }

                        });
//                        finish();

                    } else {
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                //更新UI
                                Toast.makeText(ZQUserDetailActivity.this, "保存失败" + object.optString("msg"), Toast.LENGTH_SHORT).show();

                            }

                        });

                    }
                    str = "";
                } catch (Exception ex) {
                    ex.printStackTrace();
                    runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            //更新UI
                            Toast.makeText(ZQUserDetailActivity.this, "保存失败", Toast.LENGTH_SHORT).show();

                        }

                    });
                }
            }
        });
    }


    //type 1 补充提交 2提出异议
    public void getSubData(String mCreditorRightsId,String mProid,final int type) {
        if (BankruptcyApp.tokeninfo == null || BankruptcyApp.tokeninfo.getToken() == null) {
            return;
        }
        //        shapeLoadingDialog.setLoadingText("加载中...");
        //        shapeLoadingDialog.setCanceledOnTouchOutside(false);
        //        shapeLoadingDialog.show();
        OkHttpClient okHttpClient = new OkHttpClient();
        //        HashMap<String, String> params = new HashMap<String, String>();
        Random random    = new Random();
        String rom       = random.nextLong() + "";
        String timestamp = System.currentTimeMillis() + "";
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        String userId    = SPUtils.getInstance(Consts.SPNAME).getString("userId", "");


        RequestBody requestBody = new FormBody.Builder()
                .add("appid", "1000000001")
                .add("nonce", rom)
                .add("timestamp", timestamp)

                .add("token", BankruptcyApp.tokeninfo.getToken())
                .add("userToken", userToken)

                .add("creditorRightsId", mCreditorRightsId)
                .add("creditorId", mInfo.getId())
                .add("projectId", mProid)
                .add("type", "0")

                .build();

        String url = Consts.WEBURL_DECLARATIONDETAIL;
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure( Call call, IOException e ) {

            }

            @Override
            public void onResponse( Call call, Response response ) throws IOException {

                //                shapeLoadingDialog.dismiss();

                String str = response.body().string();

                try {


                    JSONObject object = new JSONObject(str);
                    if (object.optInt("code") == 0) {
                        //                        JSONObject dataobj = object.getJSONObject("data");
                        //                        JSONObject groupListobj = dataobj.getJSONObject("groupList");
                        //                        Iterator<String> it = groupListobj.keys();
                        //                        List<ManagerUserInfo> list = new ArrayList<>();
                        Gson gson = new Gson();
//                        zqUserDetailInfo.clear();
                        final ZQBaseInfo info = gson.fromJson(object.optString("data"), ZQBaseInfo.class);

                        JSONObject data = object.getJSONObject("data");
//                        ZQUserDetailAuthBaseInfo mAuthBaseInfo= new Gson().fromJson(data.getJSONObject("auth").toString(), ZQUserDetailAuthBaseInfo.class);
//                        info.setAuth(mAuthBaseInfo);
                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                if(type ==1) {
                                    CreateZQBCApplyActivity.start(ZQUserDetailActivity.this, info.getProjectCrDec().getCreditorId(), mInfo.getBankruptcyProjectId(), mInfo.getIdentityBigTypes().getValue(), 0, info.getProjectCrDec());
                                }else{
                                    getSubData2(info.getProjectCrDec().getId(),mProid,type);
//                                    DissentAddActivity.start(ZQUserDetailActivity.this, info.getProjectCrDec().getCreditorId(), info.getProjectCrDec().getBankruptcyProjectId(), info.getProjectCrDec().getId(), 0);
                                }
                            }

                        });

                        str = "";

                    }else{
                        ToastUtil.getInstance(ZQUserDetailActivity.this).showShortToast(object.optString("msg"));
                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
    }

    public void getSubData2(String mCreditorRightsId,String mProid,final int type) {
        if (BankruptcyApp.tokeninfo == null || BankruptcyApp.tokeninfo.getToken() == null) {
            return;
        }
        //        shapeLoadingDialog.setLoadingText("加载中...");
        //        shapeLoadingDialog.setCanceledOnTouchOutside(false);
        //        shapeLoadingDialog.show();
        OkHttpClient okHttpClient = new OkHttpClient();
        //        HashMap<String, String> params = new HashMap<String, String>();
        Random random    = new Random();
        String rom       = random.nextLong() + "";
        String timestamp = System.currentTimeMillis() + "";
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken", "");
        String userId    = SPUtils.getInstance(Consts.SPNAME).getString("userId", "");


        RequestBody requestBody = new FormBody.Builder()
                .add("appid", "1000000001")
                .add("nonce", rom)
                .add("timestamp", timestamp)

                .add("token", BankruptcyApp.tokeninfo.getToken())
                .add("userToken", userToken)

                .add("creditorRightsId", mCreditorRightsId)
                .add("projectId", mProid)
                .add("type", "0")

                .build();

        String url = Consts.WEBURL_REVIEWDETAIL;
        Request request = new Request.Builder()
                .url(url)
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure( Call call, IOException e ) {

            }

            @Override
            public void onResponse( Call call, Response response ) throws IOException {

                //                shapeLoadingDialog.dismiss();

                String str = response.body().string();

                try {


                    JSONObject object = new JSONObject(str);
                    if (object.optInt("code") == 0) {
                        //                        JSONObject dataobj = object.getJSONObject("data");
                        //                        JSONObject groupListobj = dataobj.getJSONObject("groupList");
                        //                        Iterator<String> it = groupListobj.keys();
                        //                        List<ManagerUserInfo> list = new ArrayList<>();
                        Gson gson = new Gson();
//                        zqUserDetailInfo.clear();
                        final ZQBaseInfo info = gson.fromJson(object.optString("data"), ZQBaseInfo.class);

                        runOnUiThread(new Runnable() {

                            @Override
                            public void run() {
                                if(type ==1) {
//                                    CreateZQBCApplyActivity.start(ZQUserDetailActivity.this, info.getProjectCrDec().getCreditorId(), mInfo.getBankruptcyProjectId(), mInfo.getIdentityBigTypes().getValue(), 1, info.getProjectCrDec());
                                }else{
                                    DissentAddActivity.start(ZQUserDetailActivity.this, info.getProjectCrDec().getCreditorId(), info.getProjectCrDec().getBankruptcyProjectId(), info.getProjectCrDec().getReview().getId(), 1);
                                }
                            }

                        });

                        str = "";

                    }

                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        });
    }

    public void  getTempData(String contact)
//            (final String creditorId,final String proid)
    {
        String userToken = SPUtils.getInstance(Consts.SPNAME).getString("userToken","");
        Network.getAPIService()
                .fetchCreditorInfoTemp(userToken, creditorId,proid,"0")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        try {
                            int code = json.get("code").getAsInt();

                            if (code != 0) {
                                com.linkage.jz.bankruptcy.net.ToastUtil.showShort("请求数据错误");
                                return;
                            }

                            JsonObject data = json.getAsJsonObject("data");
                            if(data == null ) {
                                ZQUserDetailBaseInfo info = new ZQUserDetailBaseInfo();
                                info.setId(creditorId);
                                info.setBankruptcyProjectId(proid);
                                info.setContact(contact);
                                EditZQUserBaseInfoActivity.start(ZQUserDetailActivity.this, info, 0, 0);
                            }else {

                                ZQUserDetailBaseInfo info = new Gson().fromJson(json.getAsJsonObject("data"), ZQUserDetailBaseInfo.class);
                                info.setId(info.getCreditorId());
                                info.setContact(contact);
                                EditZQUserBaseInfoActivity.start(ZQUserDetailActivity.this, info, 0, 1);
                            }

//                            info.setBankruptcyProjectId(mProID);


                        }catch (Exception ex) {
                            ex.printStackTrace();
                            ZQUserDetailBaseInfo info = new ZQUserDetailBaseInfo();
                            info.setId(creditorId);
                            info.setContact(contact);
                            info.setBankruptcyProjectId(proid);
                            EditZQUserBaseInfoActivity.start(ZQUserDetailActivity.this, info, 0, 0);

                        }
                    }

                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
//                        mDataRv.onFinishRequest(true, false);
                    }
                });
    }
}
